<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="layout" content="main" />
  <g:set var="entityName" value="${message(code: 'task.label', default: 'Task')}" />
  <title><g:message code="default.edit.label" args="[entityName]" /></title>
</head>
<body>
  <div class="nav">
    <span class="menuButton"><a class="home" href="${createLink(uri: '/')}">Home</a></span>
    <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
  </div>
  <div class="body">
    <h1><g:message code="default.edit.label" args="[entityName]" /></h1>
    <g:if test="${flash.message}">
      <div class="message">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${taskInstance}">
      <div class="errors">
        <g:renderErrors bean="${taskInstance}" as="list" />
      </div>
    </g:hasErrors>
    <g:form method="post" >
      <g:hiddenField name="id" value="${taskInstance?.id}" />
      <g:hiddenField name="version" value="${taskInstance?.version}" />
      <div class="dialog">
        <table>
          <tbody>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="name"><g:message code="task.name.label" default="Name" /></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: taskInstance, field: 'name', 'errors')}">
          <g:textField name="name" value="${taskInstance?.name}" />
          </td>
          </tr>

          <tr class="prop">
            <td valign="top" class="name">
              <label for="description"><g:message code="task.description.label" default="Description" /></label>
            </td>
            <td valign="top" class="value ${hasErrors(bean: taskInstance, field: 'description', 'errors')}">
          <g:textField name="description" value="${taskInstance?.description}" />
          </td>
          </tr>

          <tr class="prop">
            <td valign="top" class="name">
              <label for="endDate"><g:message code="task.endDate.label" default="End Date" /></label>
            </td>
            <td valign="top" class="value ${hasErrors(bean: taskInstance, field: 'endDate', 'errors')}">
          <g:datePicker name="endDate" precision="day" value="${taskInstance?.endDate}"  />
          </td>
          </tr>

          <tr class="prop">
            <td valign="top" class="name">
              <label for="endPlanDate"><g:message code="task.endPlanDate.label" default="End Plan Date" /></label>
            </td>
            <td valign="top" class="value ${hasErrors(bean: taskInstance, field: 'endPlanDate', 'errors')}">
          <g:datePicker name="endPlanDate" precision="day" value="${taskInstance?.endPlanDate}"  />
          </td>
          </tr>

          <tr class="prop">
            <td valign="top" class="name">
              <label for="hours"><g:message code="task.hours.label" default="Hours" /></label>
            </td>
            <td valign="top" class="value ${hasErrors(bean: taskInstance, field: 'hours', 'errors')}">
          <g:textField name="hours" value="${fieldValue(bean: taskInstance, field: 'hours')}" />
          </td>
          </tr>

          <tr class="prop">
            <td valign="top" class="name">
              <label for="numPhase"><g:message code="task.numPhase.label" default="Num Phase" /></label>
            </td>
            <td valign="top" class="value ${hasErrors(bean: taskInstance, field: 'numPhase', 'errors')}">
          <g:textField name="numPhase" value="${fieldValue(bean: taskInstance, field: 'numPhase')}" />
          </td>
          </tr>

          <tr class="prop">
            <td valign="top" class="name">
              <label for="project"><g:message code="task.project.label" default="Project" /></label>
            </td>
            <td valign="top" class="value ${hasErrors(bean: taskInstance, field: 'project', 'errors')}">
          <g:select name="project.id"
                    from="${Project.list()}" optionKey="id"
                    value="${taskInstance?.project?.id}"
                    optionValue="name" />
          </td>
          </tr>

          <tr class="prop">
            <td valign="top" class="name">
              <label for="startDate"><g:message code="task.startDate.label" default="Start Date" /></label>
            </td>
            <td valign="top" class="value ${hasErrors(bean: taskInstance, field: 'startDate', 'errors')}">
          <g:datePicker name="startDate" precision="day" value="${taskInstance?.startDate}"  />
          </td>
          </tr>

          <tr class="prop">
            <td valign="top" class="name">
              <label for="subTasks"><g:message code="task.subTasks.label" default="Sub Tasks" /></label>
            </td>
            <td valign="top" class="value ${hasErrors(bean: taskInstance, field: 'subTasks', 'errors')}">

              <ul>
                <g:each in="${taskInstance?.subTasks?}" var="s">
                  <li><g:link controller="subTask" action="show" id="${s.id}">${s?.encodeAsHTML()}</g:link></li>
                </g:each>
              </ul>
          <g:link controller="subTask" action="create" params="['task.id': taskInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'subTask.label', default: 'SubTask')])}</g:link>

          </td>
          </tr>

          </tbody>
        </table>
      </div>
      <div class="buttons">
        <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
        <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
      </div>
    </g:form>
  </div>
</body>
</html>
